<template>
  <!-- 品牌 -->
  <div class="wrap">
    <div class="main1">
      <p class="main-t leftbordercom">我的商户</p>
      <el-card
        class="box-card"
        :body-style="{ padding: '0px' }"
        v-for="(co,index) in company"
        :key="index"
      >
        <div v-if="co.isStore == 0 || co.isTenant == 0">
          <div class="logoBox copcolor">
            <span>{{co.name}}</span>
          </div>
          <div class="button" v-if="co.auditState == 1 && co.startStatus == 1">已停用</div>
          <div
            class="button"
            v-else
            @click="selectCompany(co.auditState, co.merchantId, co.linkName, co.name, co.isStore,co.source,co.creditCode,co.isOwnAuth,co.businessScope,co.shopType)"
          >进入商户</div>
        </div>
        <!-- 服务商认领 -->
        <div v-else>
          <div class="logoBox copcolor">
            <div class="tip">
              <div class="tipText" v-if="co.auditState == 1 && co.startStatus == 0">审核通过</div>
              <div class="tipText" v-if="co.startStatus == 2">待认领商户</div>
              <div class="tipText" v-if="co.startStatus == 3">平台审核中,请稍等</div>
              <div class="tipText" v-if="co.auditState == 3 && co.startStatus == 4">审核驳回,请修改</div>
              <div class="tipText" v-if="co.auditState == 3 && co.startStatus == 5">已拒绝</div>
              <div
                class="tipText"
                v-if="co.auditState == 1 && co.startStatus == 4"
              >审核驳回,该商户已被认领,请重新提交资料或联系商户管理员为您启用账户</div>
              <div
                class="tipText"
                v-if="co.auditState == 1 && co.startStatus == 5"
              >已拒绝,该商户已被认领,请联系商户管理员为您启用账户</div>
              <div class="icon" v-if="co.startStatus == 2 || co.startStatus == 5">
                <i class="el-icon-close" @click="deleteShop(co.merchantId)"></i>
              </div>
            </div>
            <span>{{co.name}}</span>
          </div>
          <div
            class="button"
            v-if="co.startStatus == 4"
            @click="submission(co.auditState, co.merchantId, co.linkName, co.name, co.isStore, co.creditCode)"
          >提交资料</div>
          <div
            class="button"
            v-if="co.startStatus == 2"
            @click="submission(co.auditState, co.merchantId, co.linkName, co.name, co.isStore, co.creditCode)"
          >提交资料</div>
          <div
            class="button"
            v-if="co.startStatus == 0"
            @click="selectCompany(co.auditState, co.merchantId, co.linkName, co.name, co.isStore, co.source,co.creditCode,co.isOwnAuth,co.businessScope,co.shopType)"
          >进入商户</div>
          <div class="button" v-if="co.auditState == 1 && co.startStatus == 1">已停用</div>
        </div>
      </el-card>
    </div>

    <el-dialog
      width="1000px"
      title="基础信息配置"
      :visible.sync="outerVisible"
      :show-close="true"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
    >
      <el-form
        :model="ruleForm"
        :label-position="labelPosition"
        :rules="base"
        ref="ruleForm"
        label-width="90px"
        class="demo-ruleForm system"
      >
        <el-row class="rowspace" :gutter="40">
          <el-col :span="8">
            <el-form-item class label="门店名称:" prop="name">
              <el-input
                @keyup.native="replace(ruleForm.name,ruleForm,'name')"
                maxlength="16"
                :disabled="true"
                v-model="ruleForm.name"
                size="small"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item class label="门店地址:" prop="address">
              <el-input maxlength="16" v-model="ruleForm.address" :disabled="true" size="small"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item class label="法人:" prop="principal">
              <el-input
                @keyup.native="replace(ruleForm.principal,ruleForm,'principal')"
                maxlength="18"
                v-model="ruleForm.principal"
                size="small"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row class="rowspace" :gutter="40">
          <el-col :span="8">
            <el-form-item label-width="150px" class label="统一社会信用代码:" prop="creditCode">
              <el-input
                @keyup.native="replace(ruleForm.creditCode,ruleForm,'creditCode')"
                maxlength="18"
                v-model="ruleForm.creditCode"
                size="small"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item class label="联系人:" prop="linkName">
              <el-input maxlength="16" v-model="ruleForm.linkName" :disabled="true" size="small"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label-width="115px" label="联系人手机号:" prop="linkPhone">
              <el-input
                @keyup.native="replace(ruleForm.linkPhone,ruleForm,'linkPhone')"
                :disabled="true"
                maxlength="11"
                v-model="ruleForm.linkPhone"
                size="small"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row class="rowspace" :gutter="40">
          <el-col :span="8">
            <el-form-item label="邮箱:" prop="email">
              <el-input
                @keyup.native="replace(ruleForm.email,ruleForm,'email')"
                maxlength="30"
                v-model="ruleForm.email"
                size="small"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label-width="120px" label="法人身份证号码:" prop="idcardNumber">
              <el-input
                @keyup.native="replace(ruleForm.idcardNumber,ruleForm,'idcardNumber')"
                maxlength="18"
                v-model="ruleForm.idcardNumber"
                size="small"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="7">
            <el-form-item class="rowtwo" label="营业执照信息" prop="licenseUrl">
              <div class="imgbox">
                <img :src="ruleForm.licenseUrl" @click="showimg(ruleForm.licenseUrl)" alt />
              </div>
              <el-upload
                class="upload-demo"
                action="1"
                :show-file-list="false"
                :before-upload="beforeAvatarUpload"
                :http-request="uploadSectionFile"
              >
                <el-button size="small" @click="addindex('licenseUrl')" type="primary">点击上传</el-button>
              </el-upload>
            </el-form-item>
          </el-col>
          <el-col :span="7">
            <el-form-item class="rowtwo" label="法人身份证正面" prop="idcardFront">
              <div class="imgbox">
                <img :src="ruleForm.idcardFront" @click="showimg(ruleForm.idcardFront)" alt />
              </div>
              <el-upload
                class="upload-demo"
                action="1"
                :show-file-list="false"
                :before-upload="beforeAvatarUpload"
                :http-request="uploadSectionFile"
              >
                <el-button size="small" @click="addindex('idcardFront')" type="primary">点击上传</el-button>
              </el-upload>
            </el-form-item>
          </el-col>
          <el-col :span="7">
            <el-form-item class="rowtwo" label="法人身份证反面" prop="idcardReverse">
              <div class="imgbox">
                <img :src="ruleForm.idcardReverse" @click="showimg(ruleForm.idcardReverse)" alt />
              </div>
              <el-upload
                class="upload-demo"
                action="1"
                :show-file-list="false"
                :before-upload="beforeAvatarUpload"
                :http-request="uploadSectionFile"
              >
                <el-button size="small" @click="addindex('idcardReverse')" type="primary">点击上传</el-button>
              </el-upload>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>

      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="foundation('ruleForm')">下一步</el-button>
      </div>
    </el-dialog>
    <el-dialog
      width="1000px"
      class="overflow-sm"
      title="营业信息配置"
      :visible.sync="innerVisible"
      append-to-body
      :show-close="true"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
    >
      <el-form
        :model="ruleFormT"
        :label-position="labelPosition"
        :rules="camp"
        ref="ruleFormT"
        label-width="90px"
        class="demo-ruleForm system"
      >
        <el-row :gutter="40">
          <el-col>
            <el-form-item label="是否营业" prop="isBusiness">
              <el-radio-group v-model="ruleFormT.isBusiness">
                <el-radio label="0" value="0">是</el-radio>
                <el-radio label="1" value="1">否</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="40">
          <el-col :span="8">
            <el-form-item label="门店合作类型" prop="shopType" label-width="120px">
              <template>
                <el-select size="small" v-model="ruleFormT.shopType" placeholder="请选择">
                  <el-option
                    v-for="item in shopType"
                    :key="item.label"
                    :label="item.label"
                    :value="item.value"
                  ></el-option>
                </el-select>
              </template>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="门店营业时间" label-width="120px" prop="time">
              <template>
                <el-time-picker
                  size="small"
                  value-format="HH:mm:ss"
                  is-range
                  v-model="ruleFormT.time"
                  range-separator="至"
                  start-placeholder="开始时间"
                  end-placeholder="结束时间"
                  placeholder="选择时间范围"
                ></el-time-picker>
              </template>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="40">
          <el-col :span="8">
            <el-form-item prop="businessScope" label="经营范围">
              <el-checkbox-group v-model="ruleFormT.businessScope[0]" @change="Management">
                <el-checkbox :true-label="'0'" :false-label="'1'">商品售卖</el-checkbox>
              </el-checkbox-group>
              <el-radio v-model="ruleFormT.businessScope[1]" label="1">服务预约</el-radio>
              <el-radio v-model="ruleFormT.businessScope[1]" label="2">小儿游泳</el-radio>
            </el-form-item>
          </el-col>
          <el-col :span="15">
            <el-form-item label="区域" prop="area" class="rowtwo">
              <v-distpicker
                :province="ruleFormT.area.province"
                :city="ruleFormT.area.city"
                :area="ruleFormT.area.area"
                @area="onChangeArea"
                @province="onChangeProvince"
                @city="onChangeCity"
              ></v-distpicker>
              <!-- <span>{{ruleForm.area.province}}-{{ruleForm.area.city}}-{{ruleForm.area.area}}</span> -->
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="40" class="qrcodes">
          <el-col :span="8">
            <el-form-item
              label="定位"
              prop="position"
              class="rowtwo map-error-position"
              :show-message="showErrMsg"
            >
              <div class="map-demo">
                <gd-map
                  v-bind:positionMap="ruleFormT.position"
                  v-bind:permission="1"
                  v-bind:latitude="ruleFormT.latitude"
                  v-bind:longitude="ruleFormT.longitude"
                  v-on:listenToChild="showMsgFromChild"
                  v-on:handleShowErrMsg="handleShowErrMsg"
                ></gd-map>
              </div>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="详细地址" class="rowtwo rowsecond" prop="positionAddress">
              <el-input v-model="ruleFormT.positionAddress" size="small"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div class="btnBoxs">
        <el-button
          size="small"
          @click="innerVisible = false,outerVisible = true"
          style="margin-right: 20px;"
        >上一步</el-button>
        <el-button type="primary" size="small" @click="submitForm('ruleFormT')">提交</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import util from "@/util";
import {
  findUserSubMerchant,
  delMerchantByUserId,
  getFile,
  uploadFile,
  updateBaseShop,
  selectBaseShop
} from "@/api";
import { mapState } from "vuex";
import Cookies from "js-cookie";
import VDistpicker from "v-distpicker";
import gdMap from "@/components/GdMap.vue";
export default {
  data() {
    const validTelPhone = (rule, value, callback) => {
      if (value && !util.validTelPhone(value)) {
        return callback(new Error("固定电话格式不正确 "));
      } else {
        callback();
      }
    };
    const validEmail = (rule, value, callback) => {
      if (!util.validEmail(value)) {
        return callback(new Error("邮件格式不正确！"));
      } else {
        callback();
      }
    };

    const validIdentity = (rule, value, callback) => {
      if (value === "") {
        return callback();
      } else if (!util.validIdentity(value)) {
        return callback(new Error("身份证号码格式不正确！"));
      } else {
        callback();
      }
    };
    return {
      Scope: [],
      outerVisible: false,
      innerVisible: false,
      company: [],
      showMap: false,
      id: "",
      labelPosition: "left",
      radio1: "",
      permission: 0, //0:查看,1修改
      area: { province: "", city: "", area: "" },
      activeName: "first", //tab标签名称
      imgindex: "", //当前上传
      shopType: [
        {
          value: 3,
          label: "单店"
        }
      ],
      showErrMsg: false,
      ruleForm: {
        status: 0, //启用
        name: "", //门店名称
        address: "", //门店地址
        principal: "", //法人
        creditCode: "", //社会统一信用代码
        registeredCapital: "", //注册资金
        taxesType: "", //纳税人类型
        linkName: "", //联系人
        linkPhone: "", //联系电话
        fixPhone: "", //固定电话
        registeredCapital: "", //注册资金
        fax: "", //传真
        email: "", //邮箱
        remark: "", //备注
        logoUrl: "", //logoUrl
        licenseUrl: "", //营业执照
        foodUrl: "", //食品流通许可证
        idcardFront: "", //身份证正面
        idcardReverse: "", //身份证反面
        idcardNumber: "" //身份证号
      },
      ruleFormT: {
        //门店信息
        isBusiness: "0",
        businessScope: ["1"], //经营范围
        shopType: "", //门店类型,
        time: "", //营业时间
        positionAddress: "", //详细地址
        position: "", //定位信息
        latitude: "39.912139", //维度
        longitude: "116.481543", //经度
        area: { province: "", city: "", area: "" },
        storeCodeL: "", //小程序二维码
        serviceInfoId: "", //服务商信息Id
        serviceProviderTypeNumber: "T01", //服务商类型编号
        managementTypeIdList: [] //经营范围类型
      },
      serviceList: [],
      base: {
        name: [
          { required: true, message: "请输入门店名称", trigger: "blur" },
          { validator: util.checkSpace, trigger: "blur" }
        ],
        address: [
          { required: true, message: "请输入门店地址", trigger: "blur" },
          { validator: util.checkSpace, trigger: "blur" }
        ],
        principal: [
          { required: true, message: "请输入法人", trigger: "blur" },
          { validator: util.checkSpace, trigger: "blur" }
        ],
        idcardNumber: [
          { required: false, trigger: "blur" },
          { validator: validIdentity, trigger: "blur" }
        ],
        creditCode: [{ required: true, message: "请输入统一社会信用代码" }],
        linkName: [{ required: true, message: "请输入联系人" }],
        linkPhone: [
          { required: true, message: "请输入手机号" },
          { validator: util.validatePhone, trigger: "blur" }
        ],

        licenseUrl: [{ required: true, message: "公司营业执照信息（副本)" }],
        idcardFront: [{ required: true, message: "法人身份证正面电子版" }],
        idcardReverse: [{ required: true, message: "法人身份证反面电子版" }],
        fixPhone: [{ validator: validTelPhone, trigger: "blur" }],
        email: [
          { required: true, message: "请填写邮箱" },
          { validator: validEmail, trigger: "blur" }
        ]
      },
      managementTypeList: [], //经营类型
      camp: {
        shopType: [
          { required: true, message: "请选择门店类型", trigger: "change" }
        ],
        time: [
          {
            // type: 'date',
            required: true,
            message: "请选择营业时间",
            trigger: "change"
          }
        ],
        position: [{ required: true, message: "请填写定位信息" }],
        positionAddress: [{ required: true, message: "请填写详细地址" }],
        area: [{ required: true, message: "请选择区域", trigger: "change" }],
        businessScope: [
          {
            // type: 'array',
            required: true,
            message: "请选择经营范围",
            trigger: "change"
          }
        ]
      },
      sessionData: {
        companyName: "",
        merchantId: "",
        linkName: "",
        isShop: "",
        soUrce: "",
        isOwnAuth: "",
        businessScope: "",
        shopType: ""
      }
    };
  },
  computed: mapState(["userId", "linkName", "mobile"]),
  components: {
    gdMap,
    VDistpicker
  },
  mounted() {
    //切换商户时清除菜单
    this.$store.commit("SET_PRIVILEGETREE", undefined);
    // 如果从登陆页面过来的 则减少请求数量直接使用
    // if (typeof merchantList == "undefined") {
      this.getdata();
    // } else {
    //   this.company = merchantList;
    // }
  },
  methods: {
    replace(value, obj, key) {
      let that = this;
      let event = event || window.event;
      if (event.keyCode == 13) {
        setTimeout(() => {
          that.validItem(value, obj, key);
        }, 100);
      } else {
        that.validItem(value, obj, key);
      }
    },
    validItem(value, obj, key) {
      let res = "";
      switch (key) {
        case "name":
          res = util.replaceChineseAndBracket(value);
          break;
        case "linkName":
        case "principal":
          res = util.replaceChineseAndLetter(value);
          break;
        case "linkPhone":
        case "mobile":
          res = util.replaceNumber(value);
          break;
        case "fixPhone":
          res = util.replaceFixPhone(value);
          break;
        case "email":
          res = util.replaceEmail(value);
          break;
        case "creditCode":
        case "idcardNumber":
        case "foodLicenseNumber":
          res = util.replaceSocialCreditCode(value);
          break;
        case "registeredCapital":
          res = util.twoDecimal(value);
          break;
        case "fax":
          res = util.moreThanZero(value);
          break;
      }
      this.$set(obj, key, res);
    },
    //提交
    foundation(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          this.innerVisible = true;
          this.outerVisible = false;
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    submitForm(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          if (this.ruleFormT.area.area.length < 2) {
            this.$message.error("请选择区域");
            return;
          }
          if (
            this.ruleFormT.businessScope[0] == "1" &&
            this.ruleFormT.businessScope.length == 1
          ) {
            this.$message.error("请选择经营范围");
            return;
          }
          this.ruleFormT.openTime = this.ruleFormT.time[0];
          this.ruleFormT.closedTime = this.ruleFormT.time[1];
          this.Scope = this.ruleFormT.businessScope;
          let a = this.ruleFormT.businessScope;
          this.ruleFormT.businessScope = a.toString();
          this.ruleFormT.customerNature = this.customerNature;
          let postdata = JSON.parse(JSON.stringify(this.ruleFormT));
          postdata.area =
            this.ruleFormT.area.province +
            "," +
            this.ruleFormT.area.city +
            "," +
            this.ruleFormT.area.area;
          postdata.businessId = this.merchantId;
          postdata.source = 5; //2：商户平台门店管理；3：商户平台供应商管理；4：商户平台客户管理'
          postdata.type = 3;
          postdata.isStore = 0;
          postdata.isTenant = 1;
          postdata.status = 0;
          postdata.id = this.id;
          postdata.oldLinkPhone = this.ruleForm.linkPhone;
          Object.assign(postdata, this.ruleForm);
          updateBaseShop(postdata).then(res => {
            if (res.code == 200) {
              this.saveObject(
                this.sessionData.companyName,
                this.sessionData.merchantId,
                this.sessionData.linkName,
                this.sessionData.isShop,
                this.sessionData.soUrce,
                this.sessionData.isOwnAuth,
                this.sessionData.businessScope,
                this.sessionData.shopType
              );
              this.innerVisible = false;
              this.outerVisible = false;
              if (this.auditState == 1) {
                if (this.linkNames == "") {
                  util.routerReplace("/home/personal-center", { pageState: 0 });
                } else {
                  util.routerReplace("/");
                }
              } else {
                util.routerReplace("/application/entry-application", {
                  merchantId: this.merchantId
                });
              }
            } else {
              this.ruleFormT.businessScope = this.Scope;
            }
          });
        } else {
          this.$message.error("请检查必填信息");
          return false;
        }
      });
    },
    getdata() {
      findUserSubMerchant({
        userId: this.userId,
        phone: this.mobile
      }).then(res => {
        if (res.code == 200) {
          this.company = res.data.merchantList;
        }
      });
    },
    selectCompany(
      auditState,
      merchantId,
      linkName,
      companyName,
      isShop,
      soUrce,
      creditCode,
      isOwnAuth,
      businessScope,
      shopType
    ) {
      this.auditState = auditState;
      this.merchantId = merchantId;
      this.linkNames = linkName;
      this.sessionStorageSave(
        companyName,
        merchantId,
        linkName,
        isShop,
        soUrce,
        isOwnAuth,
        businessScope,
        shopType
      );

      if (soUrce == 5 && creditCode == "") {
        this.getdeteils(this.merchantId);
        this.outerVisible = true;
      } else {
        this.saveObject(
          companyName,
          merchantId,
          linkName,
          isShop,
          soUrce,
          isOwnAuth,
          businessScope,
          shopType
        );
        // this.$store.commit("SET_PRIVILEGETREE", undefined);
        // Cookies.set(process.env.COOKIE_NAME + "_companyName", companyName);
        // this.$store.commit("SET_COMPANYNAME", companyName);
        // Cookies.set(process.env.COOKIE_NAME + "_merchantId", merchantId);
        // this.$store.commit("SET_MERCHANTID", merchantId);
        // Cookies.set(process.env.COOKIE_NAME + "_linkName", linkName);
        // this.$store.commit("SET_LINKNAME", linkName);
        // Cookies.set(process.env.COOKIE_NAME + "_isShop", isShop);
        // this.$store.commit("SET_ISSHOP", isShop);
        // Cookies.set(process.env.COOKIE_NAME + "_soUrce", soUrce); //来源
        // this.$store.commit("SET_SOURCE", soUrce);
        // Cookies.set(process.env.COOKIE_NAME + "_isOwnAuth", isOwnAuth); //自主管理
        // this.$store.commit("SET__ISOWNAUTH", isOwnAuth);
        // Cookies.set(process.env.COOKIE_NAME + "_businessScope", businessScope); //门店经营范围
        // this.$store.commit("SET__BUSINESSSCOPE", businessScope);
        // //门店类型
        // Cookies.set(process.env.COOKIE_NAME + "_shopType", shopType); //门店类型
        //       this.$store.commit("SET_SHOPTYPE", shopType);

        if (auditState == 1) {
          if (linkName == "") {
            util.routerReplace("/home/personal-center", { pageState: 0 });
          } else {
            util.routerReplace("/");
          }
        } else {
          util.routerReplace("/application/entry-application", {
            merchantId: merchantId
          });
        }
      }
    },
    submission(
      auditState,
      merchantId,
      linkName,
      companyName,
      isShop,
      creditCode
    ) {
      Cookies.set(process.env.COOKIE_NAME + "_companyName", companyName);
      this.$store.commit("SET_COMPANYNAME", companyName);
      Cookies.set(process.env.COOKIE_NAME + "_merchantId", merchantId);
      this.$store.commit("SET_MERCHANTID", merchantId);
      Cookies.set(process.env.COOKIE_NAME + "_linkName", linkName);
      this.$store.commit("SET_LINKNAME", linkName);
      Cookies.set(process.env.COOKIE_NAME + "_isShop", isShop);
      this.$store.commit("SET_ISSHOP", isShop);
      util.routerReplace("/application/business-claim", {
        creditCode: creditCode
      });
    },
    deleteShop(merchantId) {
      var data = {
        userId: this.userId,
        merchantId: merchantId
      };
      var self = this;
      self
        .$confirm("确认删除当前商户吗?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        })
        .then(() => {
          delMerchantByUserId(data).then(res => {
            self.$alert("删除成功", "提示", {
              confirmButtonText: "确定",
              callback: () => {
                location.reload();
              }
            });
          });
        })
        .catch(() => {
          self.$message({
            type: "info",
            message: "已取消删除"
          });
        });
    },
    Management(val) {
      console.log(this.ruleFormT.businessScope);
    },
    onChangeCity(val) {
      this.ruleFormT.area.city = val.value;
    },
    onChangeProvince(val) {
      this.ruleFormT.area.province = val.value;
    },
    onChangeArea(val) {
      this.ruleFormT.area.area = val.value;
    },
    //地图
    showMsgFromChild(data) {
      this.ruleFormT.position = data.address;
      this.ruleFormT.latitude = data.position[1];
      this.ruleFormT.longitude = data.position[0];
      if (this.ruleFormT.positionAddress == "") {
        this.ruleFormT.positionAddress = data.address;
      } else {
        this.ruleFormT.positionAddress = this.ruleFormT.positionAddress;
      }
    },
    handleShowErrMsg(data) {
      this.showErrMsg = data;
    },
    //区别上传图片
    addindex(i) {
      this.imgindex = i;
    },
    //图片大小格式
    beforeAvatarUpload(file) {
      const isJPG =
        file.type === "image/png" ||
        file.type === "image/jpg" ||
        file.type === "image/jpeg";
      const isLt2M = file.size / 1024 / 1024 < 2;

      if (!isJPG) {
        this.$message.error("上传图片格式错误!");
      }
      if (!isLt2M) {
        this.$message.error("只能上传jpg/png文件，且不超过2M!");
      }
      return isJPG && isLt2M;
    },
    //上传
    uploadSectionFile(param) {
      var fileObj = param.file;
      var data = new FormData();
      data.append("projectName", fileObj.name);
      data.append("file", fileObj);
      uploadFile(data).then(res => {
        if (res.code == 200) {
          let a = `${getFile}?id=${res.data.id}`;
          switch (this.imgindex) {
            case "logoUrl":
              this.ruleForm.logoUrl = a;
              break;
            case "licenseUrl":
              this.ruleForm.licenseUrl = a;
              break;
            case "foodUrl":
              this.ruleForm.foodUrl = a;
              break;
            case "idcardFront":
              this.ruleForm.idcardFront = a;
              break;
            case "idcardReverse":
              this.ruleForm.idcardReverse = a;
              break;
            default:
              break;
          }
        } else {
          this.$message({
            message: "图片上传失败",
            type: "error"
          });
        }
      });
    },
    //查询商户详情
    getdeteils(id) {
      let data = {
        id: id
      };
      selectBaseShop(data).then(res => {
        if (res.code == 200) {
          this.ruleForm.deployType = res.data.deployType;
          this.ruleForm.checkDate = res.data.checkDate;
          this.ruleForm.checkCycle = res.data.checkCycle;
          this.ruleForm.name = res.data.name;
          this.ruleForm.linkPhone = res.data.linkPhone; // //商户手机号
          this.ruleForm.address = res.data.address;
          this.ruleForm.linkName = res.data.linkName;
          this.id = res.data.id;
        }
      });
    },
    saveObject(
      companyName,
      merchantId,
      linkName,
      isShop,
      soUrce,
      isOwnAuth,
      businessScope,
      shopType
    ) {
      this.$store.commit("SET_PRIVILEGETREE", undefined);
      Cookies.set(process.env.COOKIE_NAME + "_companyName", companyName);
      this.$store.commit("SET_COMPANYNAME", companyName);
      Cookies.set(process.env.COOKIE_NAME + "_merchantId", merchantId);
      this.$store.commit("SET_MERCHANTID", merchantId);
      Cookies.set(process.env.COOKIE_NAME + "_linkName", linkName);
      this.$store.commit("SET_LINKNAME", linkName);
      Cookies.set(process.env.COOKIE_NAME + "_isShop", isShop);
      this.$store.commit("SET_ISSHOP", isShop);
      Cookies.set(process.env.COOKIE_NAME + "_soUrce", soUrce); //来源
      this.$store.commit("SET_SOURCE", soUrce);
      Cookies.set(process.env.COOKIE_NAME + "_isOwnAuth", isOwnAuth); //自主管理
      this.$store.commit("SET__ISOWNAUTH", isOwnAuth);
      Cookies.set(process.env.COOKIE_NAME + "_businessScope", businessScope); //门店经营范围
      this.$store.commit("SET__BUSINESSSCOPE", businessScope);
      //门店类型
      Cookies.set(process.env.COOKIE_NAME + "_shopType", shopType); //门店类型
      this.$store.commit("SET_SHOPTYPE", shopType);
    },
    sessionStorageSave(
      companyName,
      merchantId,
      linkName,
      isShop,
      soUrce,
      isOwnAuth,
      businessScope,
      shopType
    ) {
      this.sessionData = {
        companyName: companyName,
        merchantId: merchantId,
        linkName: linkName,
        isShop: isShop,
        soUrce: soUrce,
        isOwnAuth: isOwnAuth,
        businessScope: businessScope,
        shopType: shopType
      };
    }
  }
};
</script>
<style>
.overflow-sm .el-dialog {
  overflow-x: auto;
}
.map-content {
  width: 100%;
  height: 200px;
}
.map-demo {
  width: 100%;
  height: 200px;
}
.map-error-position .el-form-item__error {
  top: 20%;
}
</style>

<style scoped>
* {
  box-sizing: border-box;
}
.btnBoxs {
  width: 200px;
  margin: 20px 0 20px 750px;
}
.imgbox {
  width: 180px;
  height: 150px;
  border: 1px dashed #dcdfe6;
}
.imgbox img {
  width: 100%;
  height: 100%;
}
.tip {
  position: absolute;
  top: 10px;
  left: 14px;
  right: 14px;
  overflow: hidden;
}
.tip .tipText {
  float: left;
  text-align: left;
}
.tip .icon {
  float: right;
}
.button {
  background-color: #3abfbf;
  width: 100px;
  height: 30px;
  line-height: 30px;
  border-radius: 5px;
  margin: 15px auto 0;
  font-size: 14px;
  color: #fff;
}
a {
  color: black;
  text-decoration: none;
}
.logo {
  height: 35px;
}
.logodiv {
  height: 100%;
  padding-top: 10px;
}
.userwrap {
  display: flex;
  align-items: center;
  color: #fff;
}
.userwrap > span {
  margin-right: 10px;
}

.box-card {
  width: 360px;
  display: inline-block;
  height: 212px;
  text-align: center;
  padding: 0;
  margin-left: 30px;
  margin-bottom: 15px;
  color: #535353;
}

.logoBox {
  width: 100%;
  height: 146px;
  display: flex;
  display: -webkit-flex;
  color: #fff;
  align-items: center;
  justify-content: center;
  position: relative;
}
.logoBox > span {
  font-weight: bold;
}
.copname {
  line-height: 66px;
}
.copcolor {
  background-color: #3abfbf;
}
.wrap {
  width: 1280px;
  height: 100%;
  margin: 0 auto;
  position: relative;
}
.main1 {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 30px;
  text-align: left;
}

.main1 .main-t {
  margin: 20px 60px;
  padding-left: 10px;
  text-align: left;
}
.leftbordercom {
  border-left: 1px solid #3abfbf;
}
.leftborderstr {
  border-left: 1px solid #ec8640;
}
.main1 ul li {
  list-style: none;
}
.icon,
.button {
  cursor: pointer;
}
</style>
